package Work04.Task01;

/**
 * @Author: lu
 * @Date: 2021/9/14 9:09
 * @Description:
 */
public class Staff {
    private String name;
    private int age;

    public Staff() {
    }

    public Staff(String name, int age) {
        if(age >150||age<0){
            throw  new RuntimeException("年龄异常");
        }else {
            this.age = age;
        }
        if(name == null || name.equals("")){
            throw new RuntimeException("空异常");
        }else{
            this.name = name;
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Staff{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
